package view;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JTabbedPane;

import view.paneles.PanelEnviarPALC;
import view.paneles.PanelInicio;
import view.paneles.PanelRecibirEnvT;
import view.paneles.PanelRecibirOfAD;
import view.paneles.PanelVenta;
import framework.Vista;

public class VentanaCliente extends JFrame {
	private static final long serialVersionUID = -3934051860624769650L;

	Vista vistaMadre;
	GridBagLayout layout;
	GridBagConstraints c;
	JTabbedPane tabbedPane;
	String url="C:/NaibergerPantano/Workspace/ZaraTienda-Cliente/src/zara.gif";
	

	public VentanaCliente(Vista vista) {
		this.vistaMadre = vista;
		this.setTitle("Zara | Tienda");
		this.layout = new GridBagLayout();
		this.c = new GridBagConstraints();
		this.setLayout(layout);
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		this.setResizable(false);
		this.setIconImage(Toolkit.getDefaultToolkit().getImage(url));
	}


	public void setTabbedPaneEnabled(boolean enabled) {
		this.tabbedPane.setEnabled(enabled);
	}

	public void setInicioLogin(boolean login) {
		if (login) {
			this.tabbedPane.setComponentAt(0, new PanelInicio(this.vistaMadre,PanelInicio.LOGIN));
		} else {
			this.tabbedPane.setComponentAt(0, new PanelInicio(this.vistaMadre,PanelInicio.SESSION));
		}
	}
	
	public void loadTabbedPane (){
		tabbedPane = new JTabbedPane(JTabbedPane.TOP,JTabbedPane.SCROLL_TAB_LAYOUT);

		tabbedPane.addTab("Inicio",new PanelInicio(this.vistaMadre,PanelInicio.LOGIN));
		tabbedPane.addTab("Venta",new PanelVenta(this.vistaMadre));
		tabbedPane.addTab("Recibir OfAD",new PanelRecibirOfAD(this.vistaMadre));
		tabbedPane.addTab("Enviar PALC",new PanelEnviarPALC(this.vistaMadre));
		tabbedPane.addTab("Recibir EnvT",new PanelRecibirEnvT(this.vistaMadre));
		tabbedPane.setEnabled(true);

		c.gridx = 0;
		c.gridy = 0;
		c.gridwidth = 1;
		c.gridheight = 1;
		c.fill = GridBagConstraints.BOTH;
		c.ipady = 0;
		c.ipadx = 0;
		c.insets = new Insets(4, 6, 2, 6);
		c.anchor = GridBagConstraints.WEST;
		c.weightx = 1;
		c.weighty = 1;
		this.add(tabbedPane,c);
	}

}
